This repository was archived by the owner on May 29, 2026. It is now read-only.
refactor(mcp): decompose OpenBuiltToolProvider (reduce PHPMD complexity, behavior-preserving)#153
Merged
Conversation
…ty, no behavior change)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Pure extract-and-delegate refactor of
lib/Mcp/OpenBuiltToolProvider.php. No behavior change — every branch, return shape, exception, MCP tool name/schema, and side effect is preserved identically.Why
OpenBuiltToolProviderwas 1165 lines with PHPMD violations:lib/Mcp/PHPMD overallWhat was extracted
9 new files under
lib/Mcp/Handler/:AbstractToolHandler— shared base:errorResult,requireAuthenticatedUser,isValidSlug,buildDeepLink,sourceDescriptor,toArray,extractUuid,loadVersion,saveVersionManifestListAppsHandler—openbuilt.listAppsGetAppManifestHandler—openbuilt.getAppManifestCreateAppHandler—openbuilt.createAppPromoteVersionHandler—openbuilt.promoteVersionUpsertSchemaHandler—openbuilt.upsertSchema(also extractsvalidateSlugsAndTitle+normaliseSchemaBody+findExistingSchema+attachSchemaToRegister)UpsertPageHandler—openbuilt.upsertPage(extractsupsertPageInList)AddWidgetHandler—openbuilt.addWidget(extractsfindPageIndex+appendWidget)UpsertMenuItemHandler—openbuilt.upsertMenuItem(extractsupsertMenuItemInList)OpenBuiltToolProvideris now a thin dispatcher: constants →TOOL_DESCRIPTORS→invokeTool(string-map lookup) →makeHandlerfactory → handler.handle($args). TheisAdminpublic method stays in the provider (sole user ofIGroupManager).Verification
php -l— no syntax errors on all 10 filesvendor/bin/phpmd lib/Mcp text design,codesize— exit 0, 0 violationsvendor/bin/phpstan analyse lib --no-progress— exit 0, no errorsvendor/bin/phpcs --standard=phpcs.xml lib/Mcp— 0 errors (pre-existing@specwarnings only, identical to original)vendor/bin/phpunit tests/Unit— 192 tests, 111 pre-existing errors (allOCA\OpenRegister\Service\ObjectService not exist— same count before and after; no NC environment)What remains inline / why
Nothing handler-logic lives in the provider. The
@specwarning on public methods is pre-existing on the original file and requires a project-level spec ticket — out of scope for a complexity refactor.